package  
{
	import flash.display.DisplayObject;
	import flash.display.Stage;
	import flash.events.KeyboardEvent;
	import interfaces.IOperate;
	/**
	 * 键盘事件管理器keyboard
	 * @author WLDragon 2014-02-27
	 */
	public class Kyb 
	{
		static public function init(main:DisplayObject):void
		{
			var s:Stage = main.stage;
			s.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);
		}
		
		static private function onKeyDown(e:KeyboardEvent):void 
		{
			if (curOperater)
				curOperater.execute(e.keyCode);
		}
		
		/**
		 * 设置操作的类
		 * @param	operater 操作对象，传入null表示禁用键盘
		 */
		static public function setOperater(operater:IOperate):void
		{
			curOperater = operater;
		}
		
		/**当前执行键盘操作的类*/
		static private var curOperater:IOperate;
		
	}

}